{extend name="main_mobile"}
{block name="style"}
<style type="text/css">
	.w-100px{width: 100px;}
</style>
{/block}
{block name="body"}
<div class="bg-white mb-3 table-responsive p-3">
	<el-form :model="search" @submit.native.prevent="submitForm" ref="search"
	label-position="right">

	<div class="flex flex-center">
		<div class="mx-1 flex-1">
			<el-input v-model="search.uid" placeholder="UID" clearable></el-input>
		</div>
		<el-button type="primary" @click="sendHtml">查询</el-button>
		<span class="text-nowrap px-2 py-3 small text-secondary"
		@click="searchMore= !searchMore">{{searchMore?'收起':'更多'}}</span>
	</div>
	<div v-show="searchMore" style="display: none;" class="mt-3">

		<el-form-item label="应用" prop="app_id">
			<el-input v-model="search.app_id" placeholder="APPID"></el-input>
		</el-form-item>

		<el-form-item label="接口" prop="api_id">
			<el-input v-model="search.api_id" placeholder="接口ID"></el-input>
		</el-form-item>

		<el-form-item label="IP" prop="ip">
			<el-input v-model="search.ip" placeholder="IP"></el-input>
		</el-form-item>

		<el-form-item label="时间" prop="time">
			<el-date-picker
			v-model="search.time"
			type="daterange"
			align="left"
			range-separator="至"
			start-placeholder="开始日期"
			end-placeholder="结束日期"
			format="yyyy-M-d"
			value-format="yyyy-M-d"
			:picker-options="pickerOptions">
		</el-date-picker>
	</el-form-item>
</div>
</el-form>
</div>

<div class="bg-white mb-2 p-3" v-for="(v,index) in tableData">
	<div class="flex flex-center">
		<div class="flex flex-center flex-1">
			<el-image
			v-if="v.headimg" 
			style="width: 30px; height: 30px"
			lazy
			class="rounded-circle mr-2"
			:src="v.headimg" 
			:preview-src-list="[v.headimg]">
		</el-image>
		<div class="text-small" v-if="v.uid">
			<div>{{v.nickname}}</div>
			<div>{{v.uid}}</div>
		</div>
	</div>
	<div class="text-secondary text-small">ID:{{v.id}}</div>
</div>
<div class="flex pt-2">
	<div class="flex-1 flex flex-center">
		<div class="w-50px text-grey">应用</div>
		<div class="flex-1">{{ v.app_name }}</div>
	</div>
	<div class="flex-1 flex flex-center">
		<div class="w-50px text-grey">Title</div>
		<div class="flex-1">{{ v.title }}</div>
	</div>
</div>
<div class="flex pt-2">
	<div class="flex-1 flex flex-center">
		<div class="w-50px text-grey">IP</div>
		<div class="flex-1">{{ v.ip }}</div>
	</div>
</div>
<div class="flex pt-2">
	<div class="flex-1 flex flex-center">
		<div class="w-50px text-grey">平台</div>
		<div class="flex-1">{{ v.systype }}</div>
	</div>
</div>
<div class="flex pt-2">
	<div class="flex-1 flex flex-center">
		<div class="w-50px text-grey">参数</div>
		<div class="flex-1">{{ v.param }}</div>
	</div>
</div>
<div class="flex pt-2">
	<div class="flex-1 flex flex-center">
		<div class="w-50px text-grey">访问</div>
		<div class="flex-1">{{ v.create_time }}</div>
	</div>
</div>
</div>
<div class="table-responsive py-3 text-center">
	<el-pagination
	background
	@size-change="handleSizeChange"
	@current-change="handleCurrentChange"
	:current-page="search.page"
	:page-sizes="[10,50,100,200]"
	:page-size="search.pageSize"
	layout="total, sizes, prev, next"
	:total="search.total">
</el-pagination>
</div>

{/block}
{block name="script"}
<script type="text/javascript">
	var vm=new Vue({
		el:'#app',
		data:{
			view:XYBase.view,
			searchMore:false,
			payInfo: {},
			labelPosition:'right',
			pickerOptions: {
				shortcuts: [{
					text: '最近一周',
					onClick(picker) {
						const end = new Date();
						const start = new Date();
						start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
						picker.$emit('pick', [start, end]);
					}
				}, {
					text: '最近一个月',
					onClick(picker) {
						const end = new Date();
						const start = new Date();
						start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
						picker.$emit('pick', [start, end]);
					}
				}, {
					text: '最近三个月',
					onClick(picker) {
						const end = new Date();
						const start = new Date();
						start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
						picker.$emit('pick', [start, end]);
					}
				}, {
					text: '最近半年',
					onClick(picker) {
						const end = new Date();
						const start = new Date();
						start.setTime(start.getTime() - 3600 * 1000 * 24 * 180);
						picker.$emit('pick', [start, end]);
					}
				}]
			},
			search:{
				uid:'{notempty name=":request()->get('uid')"}{:request()->get('uid')}{/notempty}',
				app_id:'',
				api_id:'',
				ip:'',
				time:[],
				ajax:false,
				page:1,
				total:0,
				pageSize:10
			},
			tableData:[],
		},
		watch:{
			view:XYBase.viewWatch,
		},
		created(){
			XYBase.created(this);
		},
		methods: {
			resetForm:function(formName) {
				this.$refs[formName].resetFields();
			},
			handleSizeChange(val) {
				this.search.page=1;
				this.search.pageSize=val;
				this.initHtml();
			},
			handleCurrentChange(val) {
				this.search.page=val;
				this.initHtml();
			},
			sendHtml(){
				this.search.page=1;
				this.initHtml();
			},
			initHtml() {
				var _this=this;
				_this.search.ajax=true;
				$.ajax({
					url:'',
					type:'get',
					data:_this.search,
					dataType:'json',
					error:function(err){
						_this.search.ajax=false;
						XYBase.error(XYBase.config.system_network_error);
					},
					success:function(ret){
						_this.search.ajax=false;
						if (ret) {
							if (ret.code === 0) {
								_this.search.total=ret.data.total;
								_this.tableData=ret.data.data;
							}else{
								XYBase.msg(ret.msg);
							}
						}else{
							XYBase.error(XYBase.config.system_network_error);
						}
					}
				});
			},
		}
	});
	$(function(){
		vm.initHtml();
		reloadWindowSize();
		$(window).resize(function(){
			reloadWindowSize();
		});
	});
	function reloadWindowSize (argument) {
		var winW=$(window).width();
		if(winW <= 576){
			vm.labelPosition='top';
		}else{
			vm.labelPosition='right';
		}
	}
</script>
{/block}